<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Calico: calico/third_party/apriltags/apriltags/TagFamily.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Calico
   </div>
   <div id="projectbrief">A visual-inertial calibration library designed for rapid problem construction and debugging.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_e7ac338090e46d594d3ea7a0e9efc7ba.html">calico</a></li><li class="navelem"><a class="el" href="dir_65d747a460e6d1ffaba160a154370ebb.html">third_party</a></li><li class="navelem"><a class="el" href="dir_3db016810d58e96ba2daf796df211604.html">apriltags</a></li><li class="navelem"><a class="el" href="dir_4a25d34b206d743290bd9e525b1db332.html">apriltags</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">TagFamily.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef TAGFAMILY_H</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define TAGFAMILY_H</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; </div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;climits&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;stdio.h&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;apriltags//TagDetection.h&quot;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="keyword">using namespace </span>std;</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; </div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceAprilTags.html">AprilTags</a> {</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagCodes.html">   15</a></span>&#160;<span class="keyword">class </span><a class="code" href="classAprilTags_1_1TagCodes.html">TagCodes</a> {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;  <span class="keywordtype">int</span> bits;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;  <span class="keywordtype">int</span> minHammingDistance;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;  std::vector&lt;unsigned long long&gt; codes;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160; <a class="code" href="classAprilTags_1_1TagCodes.html">TagCodes</a>(<span class="keywordtype">int</span> bits, <span class="keywordtype">int</span> minHammingDistance,</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;          <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span>* codesA, <span class="keywordtype">int</span> num)</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;   : bits(bits), minHammingDistance(minHammingDistance),</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    codes(codesA, codesA+num) <span class="comment">// created vector for all entries of codesA</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;      {}</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;};</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html">   29</a></span>&#160;<span class="keyword">class </span><a class="code" href="classAprilTags_1_1TagFamily.html">TagFamily</a> {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;  <a class="code" href="classAprilTags_1_1TagFamily.html">TagFamily</a>(<span class="keyword">const</span> <a class="code" href="classAprilTags_1_1TagCodes.html">TagCodes</a>&amp; tagCodes, <span class="keyword">const</span> <span class="keywordtype">size_t</span> blackBorder);</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160; </div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="keywordtype">void</span> setErrorRecoveryBits(<span class="keywordtype">int</span> b);</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160; </div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;  <span class="keywordtype">void</span> setErrorRecoveryFraction(<span class="keywordtype">float</span> v);</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="comment">/* if the bits in w were arranged in a d*d grid and that grid was</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment">   * rotated, what would the new bits in w be?</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment">   * The bits are organized like this (for d = 3):</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="comment">   *</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="comment">   *  8 7 6       2 5 8      0 1 2</span></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment">   *  5 4 3  ==&gt;  1 4 7 ==&gt;  3 4 5    (rotate90 applied twice)</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="comment">   *  2 1 0       0 3 6      6 7 8</span></div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="comment">   */</span></div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> rotate90(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> w, <span class="keywordtype">int</span> d);</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160; </div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">int</span> hammingDistance(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> a, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> b);</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> popCountReal(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> w);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; </div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">int</span> popCount(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> w);</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160; </div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;  <span class="comment">/*  The corresponding fields of TagDetection will be filled in. */</span></div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  <span class="keywordtype">void</span> decode(<a class="code" href="structAprilTags_1_1TagDetection.html">TagDetection</a>&amp; det, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> rCode) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keywordtype">void</span> printHammingDistances() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html#add18a3ccb0b2094f5c8fc033eac69902">   64</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classAprilTags_1_1TagFamily.html#add18a3ccb0b2094f5c8fc033eac69902">blackBorder</a>;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160; </div>
<div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html#ad45fd65efdd20e0895e7717d737f2bd4">   67</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classAprilTags_1_1TagFamily.html#ad45fd65efdd20e0895e7717d737f2bd4">bits</a>;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html#a70c25d3f3802bde5122643490332f8c6">   70</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classAprilTags_1_1TagFamily.html#a70c25d3f3802bde5122643490332f8c6">dimension</a>;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160; </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <span class="comment">/*  Accounting for rotational ambiguity? The code can recover</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="comment">   *  (minHammingDistance-1)/2 bit errors.</span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="comment">   */</span></div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html#a4c431ef9dd016c283d9d5e5814be652b">   76</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classAprilTags_1_1TagFamily.html#a4c431ef9dd016c283d9d5e5814be652b">minimumHammingDistance</a>;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160; </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  <span class="comment">/* The error recovery value determines our position on the ROC</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="comment">   * curve. We will report codes that are within errorRecoveryBits</span></div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;<span class="comment">   * of a valid code. Small values mean greater rejection of bogus</span></div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="comment">   * tags (but false negatives). Large values mean aggressive</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="comment">   * reporting of bad tags (but with a corresponding increase in</span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="comment">   * false positives).</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="comment">   */</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keywordtype">int</span> errorRecoveryBits;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily.html#a68483a11d1c70e1d60c6d21fa5ffc392">   88</a></span>&#160;  std::vector&lt;unsigned long long&gt; <a class="code" href="classAprilTags_1_1TagFamily.html#a68483a11d1c70e1d60c6d21fa5ffc392">codes</a>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160; </div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span>  popCountTableShift = 12;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> popCountTableSize = 1 &lt;&lt; popCountTableShift;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> popCountTable[popCountTableSize];</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classAprilTags_1_1TagFamily_1_1TableInitializer.html">   95</a></span>&#160;  <span class="keyword">static</span> <span class="keyword">class </span><a class="code" href="classAprilTags_1_1TagFamily_1_1TableInitializer.html">TableInitializer</a> {</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  <span class="keyword">public</span>:</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    <a class="code" href="classAprilTags_1_1TagFamily_1_1TableInitializer.html">TableInitializer</a>() {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;      <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; TagFamily::popCountTableSize; i++)</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        TagFamily::popCountTable[i] = TagFamily::popCountReal(i);</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  } initializer;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;};</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160; </div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;} <span class="comment">// namespace</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="aclassAprilTags_1_1TagCodes_html"><div class="ttname"><a href="classAprilTags_1_1TagCodes.html">AprilTags::TagCodes</a></div><div class="ttdef"><b>Definition:</b> TagFamily.h:15</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_1_1TableInitializer_html"><div class="ttname"><a href="classAprilTags_1_1TagFamily_1_1TableInitializer.html">AprilTags::TagFamily::TableInitializer</a></div><div class="ttdoc">Initializes the static popCountTable.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:95</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html">AprilTags::TagFamily</a></div><div class="ttdoc">Generic class for all tag encoding families.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:29</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html_a4c431ef9dd016c283d9d5e5814be652b"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html#a4c431ef9dd016c283d9d5e5814be652b">AprilTags::TagFamily::minimumHammingDistance</a></div><div class="ttdeci">int minimumHammingDistance</div><div class="ttdoc">Minimum hamming distance between any two codes.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:76</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html_a68483a11d1c70e1d60c6d21fa5ffc392"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html#a68483a11d1c70e1d60c6d21fa5ffc392">AprilTags::TagFamily::codes</a></div><div class="ttdeci">std::vector&lt; unsigned long long &gt; codes</div><div class="ttdoc">The array of the codes. The id for a code is its index.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:88</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html_a70c25d3f3802bde5122643490332f8c6"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html#a70c25d3f3802bde5122643490332f8c6">AprilTags::TagFamily::dimension</a></div><div class="ttdeci">int dimension</div><div class="ttdoc">Dimension of tag. e.g. for 16 bits, dimension=4. Must be sqrt(bits).</div><div class="ttdef"><b>Definition:</b> TagFamily.h:70</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html_ad45fd65efdd20e0895e7717d737f2bd4"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html#ad45fd65efdd20e0895e7717d737f2bd4">AprilTags::TagFamily::bits</a></div><div class="ttdeci">int bits</div><div class="ttdoc">Number of bits in the tag. Must be n^2.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:67</div></div>
<div class="ttc" id="aclassAprilTags_1_1TagFamily_html_add18a3ccb0b2094f5c8fc033eac69902"><div class="ttname"><a href="classAprilTags_1_1TagFamily.html#add18a3ccb0b2094f5c8fc033eac69902">AprilTags::TagFamily::blackBorder</a></div><div class="ttdeci">int blackBorder</div><div class="ttdoc">Numer of pixels wide of the inner black border.</div><div class="ttdef"><b>Definition:</b> TagFamily.h:64</div></div>
<div class="ttc" id="anamespaceAprilTags_html"><div class="ttname"><a href="namespaceAprilTags.html">AprilTags</a></div><div class="ttdef"><b>Definition:</b> Edge.h:8</div></div>
<div class="ttc" id="astructAprilTags_1_1TagDetection_html"><div class="ttname"><a href="structAprilTags_1_1TagDetection.html">AprilTags::TagDetection</a></div><div class="ttdef"><b>Definition:</b> TagDetection.h:13</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
